import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

@WebServlet("/refresh")
public class RefreshServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        //1.在屏幕上显示时间戳
        resp.setHeader("refresh","1");
        resp.getWriter().println("timeStamp:" + " " + new Date().getTime());


        //2.使时间在屏幕上格式化显示
//        resp.setHeader("refresh","1");
//        SimpleDateFormat date=new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
//        Date date1=new Date();
//        String format=date.format(date1);
//        resp.setContentType("text/html;charset=utf-8");
//        resp.getWriter().println(format);
    }
}
